package daa.levelup.threads;




    abstract public class AbstractProcessor implements Runnable {
        protected DefList defList;
        private boolean workflag = true;
        private long sleepTime;
        public AbstractProcessor(DefList defList, long sleepTime) {
            this.defList = defList;
            this.sleepTime =sleepTime;
        }

        public void setWorkflag(boolean workflag) {
            this.workflag = workflag;
        }

        @Override
        public void run() {
            try {
                do {
                    doWork();
                    Thread.sleep(sleepTime);
                }
                while (workflag);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        protected abstract void doWork();
    }


